package edu.ucsd.cse135.gas.logic.chair;

import java.sql.Connection;
import java.sql.PreparedStatement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.ucsd.cse135.gas.bean.chair.DecisionParameterBean;
import edu.ucsd.cse135.gas.logic.support.Database;
import edu.ucsd.cse135.gas.resources.Constants;

public class Decision {

	public static void accept(String applicant) {
		
		try {
			Connection conn = Database.open();
			
			String sql = "UPDATE applicant SET application_status = 'Accepted' WHERE mail = ?;";
			
			PreparedStatement preStmt = conn.prepareStatement(sql);
			preStmt.setString(1, applicant);
			
			preStmt.executeUpdate();
			
			preStmt.close();
			Database.close();
		}
		catch(Exception e)
		{ 
			e.printStackTrace();
		}
		
	}
	
	public static void reject(String applicant) {
		
		try {
			Connection conn = Database.open();
			
			String sql = "UPDATE applicant SET application_status = 'Rejected' WHERE mail = ?;";
			
			PreparedStatement preStmt = conn.prepareStatement(sql);
			preStmt.setString(1, applicant);
			
			preStmt.executeUpdate();
			
			preStmt.close();
			Database.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
	}

	public static void cancel(String applicant) {
	
		try {
			Connection conn = Database.open();
			
			String sql = "UPDATE applicant SET application_status = 'Pending' WHERE mail = ?;";
			
			PreparedStatement preStmt = conn.prepareStatement(sql);
			preStmt.setString(1, applicant);
			
			preStmt.executeUpdate();
			
			preStmt.close();
			Database.close();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
	}
	
}
